using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor(typeof(Crown))]
public class CrownEditor : Editor
{
    string[] types = new string[] { "Ellipse", "Cone", "Rectangle" };
    Crown crown;

    public override void OnInspectorGUI()
    {
        crown = (Crown)target;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Crown Type:");
        crown.type = EditorGUILayout.Popup(crown.type, types);
        EditorGUILayout.EndHorizontal();

        // Ellipse
        if (crown.type == 0)
        {
            crown.ellipseRadius = EditorGUILayout.Vector2Field("Radius", crown.ellipseRadius);
            crown.ellipseDensity = EditorGUILayout.FloatField("Density", Mathf.Clamp(crown.ellipseDensity, 0f, 1f));
            crown.ellipseOffsetX = EditorGUILayout.Vector2Field("Offsets (X)", new Vector2(Mathf.Clamp(crown.ellipseOffsetX.x, -1f, crown.ellipseOffsetX.y), Mathf.Clamp(crown.ellipseOffsetX.y, crown.ellipseOffsetX.x, 1f)));
            crown.ellipseOffsetY = EditorGUILayout.Vector2Field("Offsets (Y)", new Vector2(Mathf.Clamp(crown.ellipseOffsetY.x, -1f, crown.ellipseOffsetY.y), Mathf.Clamp(crown.ellipseOffsetY.y, crown.ellipseOffsetY.x, 1f)));
        }
        
        EditorUtility.SetDirty(crown);
    }
}
